Hello Forums,
Is it possible to count the regexp Regexp Verweis = regexp2 "\\[[I][t][_]+([0-9]+)\\]"
Regards, Neven Control17 - Wed Aug 23 02:55:55 EDT 2017 |
Re: Counting Regexp Hi Neven, have a look at the DXL manual, explanation of regexp2, example program. Use the while loop for counting.
Regards, |
Re: Counting Regexp Mike.Scharnow - Wed Aug 23 05:21:01 EDT 2017 Hi Neven, have a look at the DXL manual, explanation of regexp2, example program. Use the while loop for counting.
Regards, Hi, i tried with this code
pragma runLim, 0
Module m = current
Object o
filtering off
Skip objList = create()
for o in m do {
{
Regexp Reference = regexp2 "\\[[I][t][_]+([0-9]+)\\]"
string theText = (o."Object Text" "")(o."Object Heading")
int count = 0
while (!null theText && Reference theText) {
theText = theText[end 1 + 1:]
count++
string ReferenceNumber
if (Reference theText) {
ReferenceNumber = theText[match 1]
int iReferenceNumber = intOf realOf ReferenceNumber
put (objList,iReferenceNumber,o)
}
}
}
}
but i does not find all the Reference
Regards, Neven
|
Re: Counting Regexp Control17 - Wed Aug 23 06:11:08 EDT 2017 Hi, i tried with this code
pragma runLim, 0
Module m = current
Object o
filtering off
Skip objList = create()
for o in m do {
{
Regexp Reference = regexp2 "\\[[I][t][_]+([0-9]+)\\]"
string theText = (o."Object Text" "")(o."Object Heading")
int count = 0
while (!null theText && Reference theText) {
theText = theText[end 1 + 1:]
count++
string ReferenceNumber
if (Reference theText) {
ReferenceNumber = theText[match 1]
int iReferenceNumber = intOf realOf ReferenceNumber
put (objList,iReferenceNumber,o)
}
}
}
}
but i does not find all the Reference
Regards, Neven
have any one another idea |
Re: Counting Regexp Control17 - Wed Aug 23 09:01:28 EDT 2017
have any one another idea
What do you think the code you inserted does? Did you understand the lines at all? In line 13 you remove the reference from theText, so the second pattern matching in line 16 will not be able find the reference anymore... And it is not needed, as you already executed the regexp against the string....
pragma runLim, 0
Module m = current
Object o
filtering off
Skip objList = create()
Regexp Reference = regexp2 "\\[[I][t][_]+([0-9]+)\\]"
for o in m do {
{
string theText = (o."Object Text" "")(o."Object Heading" "")
int count = 0
while (!null theText && Reference theText) {
count++
string ReferenceNumber
ReferenceNumber = theText[match 1]
int iReferenceNumber = intOf realOf ReferenceNumber
put (objList,iReferenceNumber,o)
theText = theText[end 1 + 1:]
}
print "Object " (o."Absolute Number" "") " contains " count " references.\n"
}
}
[progress] Executing /x.dxl Object 2 contains 1 references. Object 3 contains 0 references. Object 4 contains 1 references. Object 5 contains 3 references. Object 6 contains 1 references. Object 7 contains 0 references. [progress] Done. |
Re: Counting Regexp hm, I wanted to attach a screenshot of my demo module in the previous post, but IBM keeps telling me that the image is considered as spam... Attachments 2017-08-23 18_55_17-'references' current 0.0 in _Support (Fo.png |
Re: Counting Regexp Mike.Scharnow - Wed Aug 23 12:58:11 EDT 2017
What do you think the code you inserted does? Did you understand the lines at all? In line 13 you remove the reference from theText, so the second pattern matching in line 16 will not be able find the reference anymore... And it is not needed, as you already executed the regexp against the string....
pragma runLim, 0
Module m = current
Object o
filtering off
Skip objList = create()
Regexp Reference = regexp2 "\\[[I][t][_]+([0-9]+)\\]"
for o in m do {
{
string theText = (o."Object Text" "")(o."Object Heading" "")
int count = 0
while (!null theText && Reference theText) {
count++
string ReferenceNumber
ReferenceNumber = theText[match 1]
int iReferenceNumber = intOf realOf ReferenceNumber
put (objList,iReferenceNumber,o)
theText = theText[end 1 + 1:]
}
print "Object " (o."Absolute Number" "") " contains " count " references.\n"
}
}
[progress] Executing /x.dxl Object 2 contains 1 references. Object 3 contains 0 references. Object 4 contains 1 references. Object 5 contains 3 references. Object 6 contains 1 references. Object 7 contains 0 references. [progress] Done.
|